<!DOCTYPE html>
<%@page import="com.tdcy.framework.util.SessionUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>配置管理中心</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<jsp:include page="../../hcommon.jsp"></jsp:include>
</head>
<!-- 自定义js -->
<script type="text/javascript"> 
    $(document).ready(function () {
    	 $.jgrid.defaults.width = 960;
		 $.jgrid.defaults.responsive = true;
		 $.jgrid.defaults.styleUI = 'Bootstrap';
		 $.jgrid.ajaxOptions.type = 'post';
    	 initmodelGridIdTable();
    });
    
    /**
    *初始化表单
    */
    function initmodelGridIdTable() {
    	var queryParams = {};
		var colModel=[];
		var colSuspendedItem={label: '操作', name: 'userId', align: 'left',width: 200,sortable:true,formatter:operFormatter};
          colModel.push(colSuspendedItem);
		var colSuspendedItem={label: 'openId', name: 'openId', align: 'left',width: 200,sortable:true};
        colModel.push(colSuspendedItem);
        var colIdItem={label: '名称', name: 'nickname', align: 'left',width: 120,sortable:true, checkbox:true};
           colModel.push(colIdItem);
        var colDeploymentIdItem={label: '头像', name: 'headImgUrl', align: 'center',width: 60,sortable:true,formatter:imageFormatter};
           colModel.push(colDeploymentIdItem);
        var colNameItem={label: '性别', name: 'sex', align: 'center',width: 40,sortable:true,formatter:sexFormatter};
           colModel.push(colNameItem);
           var colNameItem={label: '省市', name: 'country', align: 'center',width: 120,sortable:true,formatter:ccFormatter};
           colModel.push(colNameItem);
           var colNameItem={label: '关注时间', name: 'subscribeTime', align: 'center',width: 120,sortable:true,formatter:ttFormatter};
           colModel.push(colNameItem);
           var colNameItem={label: '备注', name: 'remark', align: 'center',width: 120,sortable:true};
           colModel.push(colNameItem);
		var settings={
            postData: queryParams,
            styleUI : 'Bootstrap',
		    mtype: "get",
		    url: "${path }/wxfans/getFans",
		    prmNames:{//请求参数格式预处理
		          page:"page",
		          rows:"rows", 
		          sort:"sort",
		          order: "order"
		    },
            datatype: "json",
            colModel:colModel,
		    pageable: true,
		    page: 1,
            rowNum: 10,
            pager: "#pager_modelGridId",
            multiSort: true,
		    sortable: true,
		    sortname: "id",
		    sortorder: "asc",
		    multiselect: true,
		    shrinkToFit: true,
		    //width: auto,
		    height: 450,
		    shrinkToFit: true,
		   
		    jsonReader: {//返回参数格式处理
		        root: "data.resultsList",
		        page: "data.curPageNO",
		        total: "data.totalPage",
		        records: "data.totalRecord"
		    },
		    rownumbers: false,
		    multikey: "true",
		    autowidth: true,
           };
           $("#modelGridIdGrid").jqGrid(settings);
       };
       
   	function operFormatter(value, options, row){
  		    	 var href="";
  		         href +="<a href=\"#\" class=\"btn btn-xs btn-primary\"  onclick=\"openAdd('"+row.openId+"')\">更新备注</a>&nbsp&nbsp";
  			     href +="<a href=\"#\" class=\"btn btn-xs btn-primary\"  onclick=\"viewUserTag('"+row.openId+"')\">查看用户标签</a>&nbsp&nbsp";
  			     href +="<a href=\"#\" class=\"btn btn-xs btn-primary\"  onclick=\"addUserTag('"+row.openId+"')\">添加用户标签</a>&nbsp&nbsp";
 		    	 return href;
  		}
    
   	function imageFormatter(value, options, row){
  		    	 var href="";
  		         href +="<img src="+value+" style='width:30px;heigth:30px;'></img>&nbsp&nbsp";
 		    	 return href;
  		}
    
   	function sexFormatter(value, options, row){
  		    	if("1" == value){
  		    		return "男";
  		    	}else{
  		    		return  "女";
  		    	}
  		}


   	function ccFormatter(value, options, row){
  		    return value+" "+row["province"]+" "+row["city"];
  		}
   	
	function ttFormatter(value, options, row){
		value=value*1000;  
		    var date =  new Date(value);
		    var y = 1900+date.getYear();
		    var m = "0"+(date.getMonth()+1);
		    var d = "0"+date.getDate();
		    return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);
		}
	
   	function openAdd(openId){
   		var url = "${path}/views/jsp/wxmgt/fansRemarkAdd";
   		AppKit.openWindow(url, "修改备注", "800", "500",{"openId":openId});
   	}
   	
	function viewUserTag(openId){
   		var url = "${path}/views/jsp/wxmgt/fansTagList";
   		AppKit.openWindow(url, "查看用户标签", "800", "500",{"openId":openId});
   	}
   	
	function addUserTag(openId){
   		var url = "${path}/views/jsp/wxmgt/fansTagAdd";
   		AppKit.openWindow(url, "添加用户标签", "800", "500",{"openId":openId});
   	}
   	
   	
   	function reloadTable(){
   		$("#modelGridIdGrid").trigger("reloadGrid"); //重新载入    
   	}
   	
   	function search(){
   		var queryParams =AppKit.getQueryParam("modelGridIdGridQueryForm","id,name,dbtype"); 
        //传入查询条件参数  
        $("#modelGridIdGrid").jqGrid('setGridParam',{  
            datatype:'json',  
            postData:queryParams, //发送数据  
            page:1  
        }).trigger("reloadGrid"); //重新载入    
   	}
   	
	function iChecks()
	{
		$(".i-checks").iCheck({
	           checkboxClass: 'icheckbox_square-green',
	           radioClass: 'iradio_square-green',
	       });
	}
   </script>

</head>
<body class="gray-bg skin-1">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>
						用戶列表</h5>
					</div>
					<div class="ibox-content">
					    <div>
							<!-- 查询条件 -->
							<div id="modelGridIdGridQueryForm" class="row">
							</div>
							
							<!-- 工具栏 -->
							<div class="row">
								<div class="col-sm-12">	
								</div>
							</div>
							<div class="jqGrid_wrapper uadmin-grid-margin" >
						        <table id="modelGridIdGrid">
						        </table>
						        <div id="pager_modelGridId"></div>
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
	</div>
</body>
</html>

           